package web.language.helper

class UserController {

    def index() { }

    def login() {
        def user = User.findByLoginAndPassword(params.username, params.password)
        if (user) {
            flash.message="Login success"
            session.user = user
            session.putValue("direction", false)
            redirect(controller: "dictionary", action: "list")
        } else {
            flash.message="Login failed"
            redirect(action: "index")
        }
    }

    def logout() {
        session.user = null
        redirect(action: "index")
    }

}
